﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Moon.Sql.Test
{
    class MoonSqlFactory
    {
        private MoonSqlFactory() { }

        public static IMoonSql Create(string connectionString, DatabaseType databaseType = DatabaseType.SqlServer, int commandTimeout = 31)
        {
            IMoonSql msql = new MoonSql(connectionString, databaseType, commandTimeout);
            msql.OnExecuting = (e) =>
            {
                Console.WriteLine(e.Sql);
                Console.WriteLine(e.ParametersString);
                //Console.WriteLine($"LogId={e.LogId},Sql={e.Sql},Param={e.ParametersString}");
            };
            msql.OnExecuted = (e) =>
            {
                //Console.WriteLine($"LogId={e.LogId},Exception={e.Exception?.Message},ElapsedMilliseconds={e.ElapsedMilliseconds},ExecuteResult={e.ExecuteResult}");
            };
            return msql;
        }
    }
}
